package com.example.demo.dataobject;

import com.example.demo.model.Product;

import java.time.LocalDateTime;

/**
 * 商品数据库对象
 */
public class ProductDO {
    private String id;//主键
    private String name;//名称
    private Double price;//价格
    private Integer purchase;//销量
    private String introduction;//介绍
    private String carouselDiagram;//轮播图，这里存储多个URL，以空格隔开，第一张图为缩略图
    private LocalDateTime gmtCreated;//创建时间
    private LocalDateTime gmtModified;//修改时间

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Double getPrice() {
        return price;
    }

    public void setPrice(Double price) {
        this.price = price;
    }

    public Integer getPurchase() {
        return purchase;
    }

    public void setPurchase(Integer purchase) {
        this.purchase = purchase;
    }

    public String getIntroduction() {
        return introduction;
    }

    public void setIntroduction(String introduction) {
        this.introduction = introduction;
    }

    public String getCarouselDiagram() {
        return carouselDiagram;
    }

    public void setCarouselDiagram(String carouselDiagram) {
        this.carouselDiagram = carouselDiagram;
    }

    public LocalDateTime getGmtCreated() {
        return gmtCreated;
    }

    public void setGmtCreated(LocalDateTime gmtCreated) {
        this.gmtCreated = gmtCreated;
    }

    public LocalDateTime getGmtModified() {
        return gmtModified;
    }

    public void setGmtModified(LocalDateTime gmtModified) {
        this.gmtModified = gmtModified;
    }

    /**
     * 数据库对象转换成模型
     * @return Product商品模型
     */
    public Product toModel() {
        Product product = new Product();
        product.setId(id);
        product.setName(name);
        product.setPrice(price);
        product.setPurchase(purchase);
        product.setIntroduction(introduction);
        product.setCarouselDiagram(carouselDiagram);
        product.setGmtCreated(gmtCreated);
        product.setGmtModified(gmtModified);
        return product;
    }
}
